﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using GuoShuCan.SDK.Web.ServerControls.Manage;
using GuoShuCan.SDK.Web.Globalization;
public partial class Manage_WebConfig : UserControlBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        using (OleDbConnection conn = new OleDbConnection(DataConfig.ConnectionString))
        {
            using (OleDbCommand com = conn.CreateCommand())
            {
                switch (ILanguage.Language)
                {
                    case "zh-CN":
                        com.CommandText = "UPDATE CNConfig SET WebName = '" + this.WebName.Text.Trim() + "', WebHttp = '" + this.WebHttp.Text.Trim() + "', WebDescription = '" + this.WebDescription.Text.Trim() + "'";
                        break;
                    case "zh-TW":
                        com.CommandText = "UPDATE TWConfig SET WebName = '" + this.WebName.Text.Trim() + "', WebHttp = '" + this.WebHttp.Text.Trim() + "', WebDescription = '" + this.WebDescription.Text.Trim() + "'";
                        break;
                    case "en-US":
                        com.CommandText = "UPDATE USConfig SET WebName = '" + this.WebName.Text.Trim() + "', WebHttp = '" + this.WebHttp.Text.Trim() + "', WebDescription = '" + this.WebDescription.Text.Trim() + "'";
                        break;
                    case "ja-JP":
                        com.CommandText = "UPDATE JPConfig SET WebName = '" + this.WebName.Text.Trim() + "', WebHttp = '" + this.WebHttp.Text.Trim() + "', WebDescription = '" + this.WebDescription.Text.Trim() + "'";
                        break;
                    case "ko-KR":
                        com.CommandText = "UPDATE KRConfig SET WebName = '" + this.WebName.Text.Trim() + "', WebHttp = '" + this.WebHttp.Text.Trim() + "', WebDescription = '" + this.WebDescription.Text.Trim() + "'";
                        break;
                }
                conn.Open();
                com.ExecuteNonQuery();
            }
        }
        //System.Threading.Thread.Sleep(5000);
        base.UpdateComplete();
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        base.RegisterAsyncListControl(this.PictureButtonOperation1);
        using (OleDbConnection conn = new OleDbConnection(DataConfig.ConnectionString))
        {
            using (OleDbCommand com = conn.CreateCommand())
            {
                //com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM CNConfig";
                switch (ILanguage.Language)
                {
                    case "zh-CN":
                        com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM CNConfig";
                        break;
                    case "zh-TW":
                        com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM TWConfig";
                        break;
                    case "en-US":
                        com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM USConfig";
                        break;
                    case "ja-JP":
                        com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM JPConfig";
                        break;
                    case "ko-KR":
                        com.CommandText = "SELECT WebName, WebHttp, WebDescription FROM KRConfig";
                        break;
                }
                conn.Open();
                using (OleDbDataReader dr = com.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        this.WebName.Text = dr.IsDBNull(0) ? string.Empty : dr.GetString(0).Trim();
                        this.WebHttp.Text = dr.IsDBNull(1) ? string.Empty : dr.GetString(1).Trim();
                        this.WebDescription.Text = dr.IsDBNull(2) ? string.Empty : dr.GetString(2).Trim();
                    }
                }
            }
        }
    }
    /// <summary>
    /// 更新区域数据。
    /// </summary>
    protected override void OnUpdateCulture()
    {
        ((GuoShuCan.SDK.Web.Globalization.IUpdateCulture)this.PictureButtonOperation1).UpdateCulture();
    }
    /// <summary>
    /// 
    /// </summary>
    protected override void OnUpdateTitle()
    {
        //protected override void OnUpdateTitle()
        //{
        this.Page.Title = ((IGetLocalResourceObject)this.Page).GetLocalResourceObject("Title").ToString() + (" - [ " + this.GetLocalResourceObject("Title").ToString() + " ]");
        // }
    }
}
